// 返回长度为k且平均值大于等于value的子数组数目
// 时间复杂度：O(n)
// 空间复杂度：O(n)
function numOfSubarrays(arr, k, value) {
    let left = 0
    let right = 0
    let windowSum = 0
    let res = 0
    while (right < arr.length) {
        windowSum += arr[right] 
        if (right - left + 1 >= k) {
            if (windowSum >= k * value) {
                res += 1
            }
            windowSum -= arr[left]
            left += 1
        }
        right += 1
    }
    return res
}

let arr = [11, 13, 17, 23, 29, 31, 7, 5, 2, 3]
console.log(numOfSubarrays(arr, 3, 5));